package d1125.r214.num07;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;

public class Demo01Lambda {
    static Integer sum=0;
    public static void main(String[] args) {
        List<Integer> aa=new ArrayList<>();
        Collections.addAll(aa,20,30,89,1,5,75,15,24,58);
        //foreach()方法
           final int[] sum={0};
           aa.forEach(s-> sum[0] +=s);
           System.out.println(sum[0]);




           aa.forEach(new Consumer<Integer>() {

              @Override
              public void accept(Integer integer) {
                 if(integer==75){
                    integer=100;

                 }
              }
          });
          System.out.println(aa);



         /*   class Inter implements Consumer<Integer>{
                @Override
                sum[0]
                public void accept(Integer integer){

                }
            }

          */

        System.out.println(aa);
        Collections.sort(aa,(o1, o2) -> o1-o2);
        System.out.println(aa);
        Collections.sort(aa,(s1,s2)->s1-s2);
    }
}